#ifndef __I_UNIX_NET_PROCESSOR_H__
#define __I_UNIX_NET_PROCESSOR_H__

#include <zlib/eventsystem/I_EventSystem.h>
#include "I_UnixNet.h"
#include "I_NetHandler.h"
#include "I_UnixNetVConnect.h"

extern const int ET_CALL;
extern int ET_NET;

class UnixNetProcessor : public Processor
{
public:
	UnixNetProcessor();

	bool start(int number_of_threads, int detached = DEFAULT_THREAD_DETACHED, size_t stacksize = DEFAULT_STACK_SIZE);

	void shutdown()
	{}

	UnixNetVConnect *alloc_vc();

	Action *accept(Continuation *c, int n_threads, const IpEntry &entry, const AcceptOptions &opt);
	Action *connect_re(Continuation *c, const IpEntry &entry, const NetOptions &opt, bool reuse_current_thread = false);

	off_t net_handler_offset;
	off_t poll_poller_offset;
	off_t event_io_offset;
private:
	bool net_inited;
};

NetHandler *get_NetHandler(EThread *t);
PollPoller *get_PollPoller(EThread *t);
PollDescriptor *get_PollDescriptor(EThread *t);

extern UnixNetProcessor netProcessor;

#endif //__I_UNIX_NET_PROCESSOR_H__
